#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    int minArray(vector<int>& nums) {
        int low = 0, high = nums.size() - 1, mid;
        while(low < high){
            mid = low + (high - low) / 2;
            if(nums[mid] > nums[high])low = mid + 1;
            else if(nums[mid] < nums[high])high = mid;
            else high--;
        }
        return nums[high];
    }
};
/**
 * 2021.10.8
 * 用中间值和结尾值作比较
 */


// class Solution {
// public
//     int minArray(vectorint& nums) {
//         int low = 0, high = nums.size() - 1;
//         while(low  high){
//             int mid = (low + high)  2;
//             if(nums[low]  nums[high])return nums[low];
//             else if(nums[low] == nums[high]){
//                 if(nums[mid]  nums[low])high = mid;
//                 else if(nums[mid]  nums[low]) low = mid + 1;
//                 else{
//                     low++;
//                     high--;
//                     continue;
//                 }
//             }
//             else{
//                 if(nums[mid] = nums[low])low = mid + 1;
//                 else high = mid;
//             }
//         }
//         return min(nums[low], nums[high]);
//     }
// };

// //2021.4.9 
